package com.kakarote.examine.common;

import java.time.Duration;
import java.time.LocalDateTime;

/**
 * @author ceshi
 * @description 时间工具类
 * @date 2022/9/22 15:22
 */

public class CommonDateTimeUtil {

    /**
     * @return
     * @Description 计算审批时间
     * @Author UNIQUE
     * @Date 2022/9/22
     * @Param
     **/
    public static String examineStopTimeStr(LocalDateTime begin, LocalDateTime end) {
        Duration duration = Duration.between(begin, end);
        String minutesStr = "00";
        String hoursStr = "00";
        long minutes = duration.toMinutes();//相差的分钟数

        long hour = minutes / 60;
        if (hour > 0) {
            if (hour < 10) {
                hoursStr = "0" + String.valueOf(hour);
            } else {
                hoursStr = String.valueOf(hour);
            }
        }

        long minute = minutes % 60;
        if (minute > 0) {
            if (minute < 10) {
                minutesStr = "0" + String.valueOf(minute);
            } else {
                minutesStr = String.valueOf(minute);
            }
        }
        return hoursStr + "小时" + minutesStr + "分钟";
    }
}
